﻿using System.IO;
using System.Text;
using System.Net;
using System.Xml;

using ECCIT;

namespace ECCIT.Net.SAML2.Assertions
{
    public class Issuer : NameIDType
    {
        // Methods
        public Issuer()
        {
        }

        public Issuer(string nameID)
            : base(nameID, null, null, null, null)
        {
        }

        public Issuer(XmlElement xmlElement)
            : base(xmlElement)
        {
            if (!IsValid(xmlElement))
            {
                throw new SerializationException("The XML is not an Issuer.");
            }
        }

        public Issuer(string nameID, string nameQualifier, string spNameQualifier, string format, string spProvidedID)
            : base(nameID, nameQualifier, spNameQualifier, format, spProvidedID)
        {
        }

        public static bool IsValid(XmlElement xmlElement)
        {
            return (xmlElement.LocalName.Equals("Issuer") && xmlElement.NamespaceURI.Equals("urn:oasis:names:tc:SAML:2.0:assertion"));
        }

        public XmlElement ToXml(XmlDocument xmlDocument)
        {
            XmlElement xmlElement = xmlDocument.CreateElement("saml", "Issuer", "urn:oasis:names:tc:SAML:2.0:assertion");
            base.ToXml(xmlElement);
            return xmlElement;
        }
    }
}
